<?php

/**
 * 后台网站设置model操作
 * @author  xiaobai
 * @date    2017-01-12
 */

namespace app\common\model;

use think\Model;

class Site extends Model
{
    
    protected $pk     = 'id';

    public function find()
    {
        $find = cache('site_setting');
        if (!$find) {
            $find = $this->where(array('id'=>1))->find()->toArray();
            cache('site_setting', $find);
        }
        return $find;
    }

    /**
     * 更新单条数据
     * @param $data  修改数组
     * @return bool
     */
    public function siteSave($data, $where)
    {
        $id = $this->save($data, $where);
        if ($id !== false) {
            cache('site_setting', $data);
            return true;
        }
        return false;
    }

}
